#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent): QWidget(parent), ui(new Ui::Widget)
{
    ui->setupUi(this);

    connect(ui->btnPrintResult, &QPushButton::clicked, this, &Widget::onBtnPrintResultClick);

    mBtnGroupGender = new QButtonGroup(this);
    mBtnGroupGender->addButton(ui->rbMale_2, 0);
    mBtnGroupGender->addButton(ui->rbFemale_2, 1);
}

Widget::~Widget()
{
    delete ui;
}

/** 打印选中的结果
 * @brief Widget::btnPrintResult
 */
void Widget::onBtnPrintResultClick()
{
    QString str;

    if(ui->rbMale->isChecked()) {
        str = ui->rbMale->text();
    } else if(ui->rbFemale->isChecked()) {
        str = ui->rbFemale->text();
    }

    ui->lineEditResult->setText(str);
}
